// JavaScript Document
// var storage_support = window.sessionStorage || window.localStorage;
//
// 
//
//

var isSupport = {
// #### html5 관련	
	
	// 꼭 필요한 HTML5 그리고 HTML5 API #pubple p.247, p.262
	webDB: function()
		{
			var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
			
			if(window.openDatabase)	
			{
				return webSQL;
			}	
			else if(indexedDB)
			{
				return indexedDB;
			}
			return false;
		},
		
	postMessage: function()
		{
			if(typeof window.postMessage == 'undefined')
			{
				return false;	
			}
			return true;
		},

	autofocus: function()
		{
			var element = document.createElement('input');
			return 'autofocus' in element;		
		},	
		
	placeholder: function()
		{
			var element = document.createElement('input');
			return 'placeholder' in element;		
		}	
		
   
// 직접체크
/*
window.applicationCache
window.jQuery




// #### dom 관련	
/*
	querySelector: function()
		{
			var dom = document.querySelector('body') && document.querySelectorAll('p');
			return dom??????
		}
	getElementById
	getElementsByTagName
	getElementsByName
	getElementsByClassName
		
		
*/
}


// jQurey 지원 필수


$(function() 
{		
	// 꼭 필요한 HTML5 그리고 HTML5 API #pubple p.89		
	if(!isSupport.autofocus())
	{
		$('input[autofocus = autofocus]').focus();	
	}
	
	// 꼭 필요한 HTML5 그리고 HTML5 API #pubple p.90  # 
	if(!isSupport.placeholder())
	{
		$('[placeholder]').textPlaceholder();	
	}
	
});

//    placeholder플러그인 : http://sbcoba.tistory.com/17
(function($) {
	$.fn.textPlaceholder = function() {
		return this.each(function() {
			var that = this;
			var placeholder = that.getAttribute('placeholder');
		
			if (!placeholder) return;
			var $input = $(that);
			
			$input.attr('placeholder', '');
			
			var $placeholderDiv = $('<div/>')
				.text(placeholder)
				.addClass('text-placeholder')
				.css({'position' : 'absolute',
					  'top':$input.position().top,
					  'left':$input.position().left})
				.height($input.height())
				.width($input.width())
				.appendTo($input.parent());
		
			$placeholderDiv.click(function() {
					$input.focus();
			});
		
			$input.focus(function() {
				$placeholderDiv.hide();
			});
		
			$input.blur(function() {
				if ($(this).val()==''){
					$placeholderDiv.show();
				}
			});
		
		});  // END OF return this.each
	}
})(jQuery);
  



